
//2367.等差三元组的数目
class Solution {
public:
    int arithmeticTriplets(vector<int>& nums, int diff) {
        //使用map来存储nums中的所有值，遍历nums看map中是否存在可以组成等差三元组的数
        unordered_set<int> s;
        for(auto e:nums) s.insert(e);

        int ret=0;
        for(auto e:nums)
        if(s.count(e-diff)&&s.count(e+diff)) ret++;

        return ret;
    }
};